<template>
  <div>
    <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="defColumns"
        :dataSource="model"
        :loading="confirmLoading"
        class="j-table-force-nowrap"
        :pagination="false"
        >
      </a-table>
  </div>
</template>

<script>

  import { getAction } from '@/api/manage'
  // import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'

  export default {
    name: 'ErpPayrollLedgerDetail',
    // mixins: [JeecgListMixin, DisabledAuthFilterMixin],
    mixins: [ DisabledAuthFilterMixin],
    components: {
    },
    data () {
      return {
        model: [],
        id: '',
        url: {
          queryById: "/api/erp/hr/erpPayrollLedger/queryById",
        },
        confirmLoading: true,
        iconStyle:{"font-size":"20px"},
        // 列定义
        defColumns: [
          {
            title:'所属期间',
            align:"center",
            dataIndex: 'period',
          },
          {
            title:'基础工资',
            align:"center",
            dataIndex: 'basePay',
            width: 100,
          },
          {
            title:'年功工资（元）',
            align:"center",
            dataIndex: 'seniorityWage',
            width: 100,
          },
          {
            title:'等级工资（元）',
            align:"center",
            dataIndex: 'gradedWages',
            width: 100,
          },
          {
            title:'预发绩效',
            align:"center",
            dataIndex: 'advancePerformance',
            width: 100,
          },
          {
            title:'执业金（元）',
            align:"center",
            dataIndex: 'executiveFund',
            width: 100,
          },
          {
            title:'报告审核费',
            align:"center",
            dataIndex: 'reportApplicationFee',
            width: 100,
          },
          {
            title:'项目绩效',
            align:"center",
            dataIndex: 'projectPerformance',
            width: 100,
          },
          {
            title:'前期已结算',
            align:"center",
            dataIndex: 'settledThePreviousPeriod',
            width: 100,
          },
          {
            title:'缺勤扣款',
            align:"center",
            dataIndex: 'absenceDeduction',
            width: 100,
          },
          {
            title:'其它',
            align:"center",
            dataIndex: 'other',
            width: 100,
          },
          {
            title:'其他扣款（元）',
            align:"center",
            dataIndex: 'otherDeductions',
            width: 100,
          },
          {
            title:"应发工资",
            align:"center",
            dataIndex: 'grossPay',
            width: 100,
          },
          {
            title: new Date().getFullYear() + '年累计收入',
            align:"center",
            dataIndex: 'annualCumulativeIncome',
            width: 100,
          },
          {
            title:'下月社保',
            align:"center",
            dataIndex: 'insuranceForNextMonth',
            width: 100,
          },
          {
            title:'当月公积金',
            align:"center",
            dataIndex: 'monthBond',
            width: 100,
          },
          {
            title:new Date().getFullYear() + '年五险一金累计扣款',
            align:"center",
            dataIndex: 'yearFiveInsurancesCount',
            width: 100,
          },
          {
            title:new Date().getFullYear() + '年累计个税专项附加扣除金额',
            align:"center",
            dataIndex: 'yearSpecialCount',
            width: 100,
          },
          {
            title:new Date().getFullYear() + '年应预缴个人所得税',
            align:"center",
            dataIndex: 'yearAdvanceCount',
            width: 100,
          },
          {
            title:new Date().getFullYear() + '年已预缴个人所得税金额',
            align:"center",
            dataIndex: 'yearPaidIndividualCount',
            width: 100,
          },
          {
            title:'本期应预缴个人所得税',
            align:"center",
            dataIndex: 'currentDuePersonal',
            width: 100,
          },
          {
            title:'前期已发放',
            align:"center",
            dataIndex: 'previouslyIssued',
            width: 100,
          },
          {
            title:'实发工资（元）',
            align:"center",
            dataIndex: 'netPayment',
            width: 100,
          }
        ],
      }
    },
    props: {
      ledgerId: String
    },
    watch: {
      $route: {
        handler(to, from) {
          if(this.$route.params.id){
            this.model = [];
            this.loadData(this.$route.params.id)
          }
          this.confirmLoading = false
        },
        immediate: true
      },
      ledgerId: {
        handler(val){
          this.model = []
          if(val){
            this.loadData(val)
          }
          this.confirmLoading = false
        },
        immediate: true
      }
    },
    methods: {
      loadData(id) {
        const that = this
        getAction(this.url.queryById, { id }).then((res) => {
          if (res.success) {
            const data = res.result
            that.model.push(data);
            // const map = res.result.tableMap
            // if(map){
            //   let columns = []
            //   for(const key in map){
            //     columns.push(
            //       {
            //         title:key,
            //         align:"center",
            //         dataIndex: map[key],
            //         width: 100
            //       }
            //     )
            //   }
            //   that.defColumns = columns
            //   that.model.push(res.result)
            // }
          } else {
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
        })
      },
    }
  }
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title{
    flex: none;
    margin-right: 20px;
  }
  /deep/ .ant-card-extra{
    flex: 1;
    float: left;
  }
}
</style>
